package com.itheima.controller;

import com.itheima.api.OrderService;
import com.itheima.util.IpUtil;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController

public class OrderController {

    //注册远程实现 而@AutoWired 注入的是本地IOC中的实现
    @DubboReference(
            check = false
            ,retries = 0
            ,cluster = "failover"
            //,group = "*"
            //,version = "v1"
            ,stub = "com.itheima.api.stub.OrderServiceStub"
            //,mock = "com.itheima.api.mock.OrderServiceMock"
    )
    private OrderService orderService;


    @GetMapping("/check/{orderId}")
    public String getOrder(@PathVariable("orderId")Long orderId) {
        System.out.println(IpUtil.getRealIp()+orderService); // proxy
        return orderService.getOrder(orderId);// 底层 走网络调用 接口具体的实现 dubbo
    }

}
